Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nginx Autoinstrumentation Implementation #2033

Merged
merged 50 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
b8c883f
all a17n logic implementation
chrlic Aug 16, 2023
63a333b
nginx, podmutator tests
chrlic Aug 16, 2023
7f80360
sdk and upgrade tests
chrlic Aug 16, 2023
6e862dc
Merge branch 'open-telemetry:main' into nginx-a17n-impl
chrlic Aug 17, 2023
b5f40ce
refactor nginx + tests
chrlic Aug 17, 2023
d95391b
Readme - added Nginx
chrlic Aug 17, 2023
5efdc01
chloggen for #PR 2033
chrlic Aug 17, 2023
656cf94
tests fixes
chrlic Aug 17, 2023
f4f6510
code cleanup
chrlic Aug 17, 2023
0064edc
Merge branch 'open-telemetry:main' into nginx-a17n-impl
chrlic Sep 18, 2023
05837ae
starting supported version, secContext
chrlic Sep 18, 2023
a6519bd
Merge branch 'open-telemetry:main' into nginx-a17n-impl
chrlic Sep 25, 2023
1fd0e09
moved nginx e2e tests
chrlic Sep 25, 2023
5339311
unprivileged pods related fixes and tests
chrlic Sep 26, 2023
e15f6e0
unprivileged test fix
chrlic Sep 26, 2023
a25040c
unprivileged nginx test assert fix
chrlic Sep 26, 2023
e7118ba
typo fix
chrlic Sep 26, 2023
751fd72
resource alloc for scaling tests
chrlic Sep 26, 2023
fa763e9
typo in assert
chrlic Sep 26, 2023
dd03cb9
Merge branch 'open-telemetry:main' into nginx-a17n-impl
chrlic Sep 26, 2023
441fc66
initContainer uses securityCtx of app container
chrlic Sep 26, 2023
1ce6c9f
test for container-level securityCtx
chrlic Sep 26, 2023
d0fc72c
yaml formatting
chrlic Sep 26, 2023
49069be
nginx secCtx e2e test
chrlic Sep 26, 2023
9d879b0
typo
chrlic Sep 26, 2023
d542a03
Update README.md
chrlic Sep 27, 2023
b72f1fb
Update pkg/featuregate/featuregate.go
chrlic Sep 27, 2023
84b519f
README.md - Nginx to stageAlpha
chrlic Sep 27, 2023
4beebf0
Nginx - to StageAlpha
chrlic Sep 27, 2023
366ab81
not needed feature flag
chrlic Sep 27, 2023
15b611f
Nginx alphaStage - upgrade test cases
chrlic Sep 27, 2023
13994e9
Nginx stageAplha - reverted bundle change
chrlic Sep 27, 2023
c766285
revert of unintential change
chrlic Sep 27, 2023
ff86617
unintended change revert
chrlic Sep 27, 2023
6c8a8f2
enable f-g operator.autoinstrumentation.nginx
chrlic Sep 27, 2023
0eee285
revert
chrlic Sep 27, 2023
ad3c1b9
enable nginx featuregate
chrlic Sep 28, 2023
936a170
enable nginx featuregate
chrlic Sep 28, 2023
d461cdc
Merge branch 'main' into nginx-a17n-impl
chrlic Sep 29, 2023
0619eed
Merge branch 'main' into nginx-a17n-impl
chrlic Oct 3, 2023
594a866
merge main branch - tests and typos
chrlic Oct 3, 2023
09db2ce
multicontainer nginx fixes
chrlic Oct 3, 2023
9b44e80
formatting
chrlic Oct 3, 2023
e6568c9
Merge branch 'main' into nginx-a17n-impl
chrlic Oct 3, 2023
116ff18
Merge branch 'main' into nginx-a17n-impl
chrlic Oct 4, 2023
e2afaec
Merge branch 'main' into nginx-a17n-impl
chrlic Oct 5, 2023
11d9fec
Merge branch 'main' into nginx-a17n-impl
chrlic Oct 6, 2023
90c17b1
added Nginx version build arg
chrlic Oct 6, 2023
075baa8
Merge branch 'nginx-a17n-impl' of https://github.com/chrlic/opentelem…
chrlic Oct 6, 2023
cba0a0f
Merge branch 'main' into nginx-a17n-impl
chrlic Oct 6, 2023
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
16 changes: 16 additions & 0 deletions .chloggen/2033-nginx-autoinstrumentation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action)
component: operator

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Implementation of new Nginx autoinstrumentation.

# One or more tracking issues related to the change
issues: [2033]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ ARG AUTO_INSTRUMENTATION_NODEJS_VERSION
ARG AUTO_INSTRUMENTATION_PYTHON_VERSION
ARG AUTO_INSTRUMENTATION_DOTNET_VERSION
ARG AUTO_INSTRUMENTATION_APACHE_HTTPD_VERSION
ARG AUTO_INSTRUMENTATION_NGINX_VERSION
ARG AUTO_INSTRUMENTATION_GO_VERSION

# Build
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -ldflags="-X ${VERSION_PKG}.version=${VERSION} -X ${VERSION_PKG}.buildDate=${VERSION_DATE} -X ${VERSION_PKG}.otelCol=${OTELCOL_VERSION} -X ${VERSION_PKG}.targetAllocator=${TARGETALLOCATOR_VERSION} -X ${VERSION_PKG}.operatorOpAMPBridge=${OPERATOR_OPAMP_BRIDGE_VERSION} -X ${VERSION_PKG}.autoInstrumentationJava=${AUTO_INSTRUMENTATION_JAVA_VERSION} -X ${VERSION_PKG}.autoInstrumentationNodeJS=${AUTO_INSTRUMENTATION_NODEJS_VERSION} -X ${VERSION_PKG}.autoInstrumentationPython=${AUTO_INSTRUMENTATION_PYTHON_VERSION} -X ${VERSION_PKG}.autoInstrumentationDotNet=${AUTO_INSTRUMENTATION_DOTNET_VERSION} -X ${VERSION_PKG}.autoInstrumentationGo=${AUTO_INSTRUMENTATION_GO_VERSION} -X ${VERSION_PKG}.autoInstrumentationApacheHttpd=${AUTO_INSTRUMENTATION_APACHE_HTTPD_VERSION}" -a -o manager main.go
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -ldflags="-X ${VERSION_PKG}.version=${VERSION} -X ${VERSION_PKG}.buildDate=${VERSION_DATE} -X ${VERSION_PKG}.otelCol=${OTELCOL_VERSION} -X ${VERSION_PKG}.targetAllocator=${TARGETALLOCATOR_VERSION} -X ${VERSION_PKG}.operatorOpAMPBridge=${OPERATOR_OPAMP_BRIDGE_VERSION} -X ${VERSION_PKG}.autoInstrumentationJava=${AUTO_INSTRUMENTATION_JAVA_VERSION} -X ${VERSION_PKG}.autoInstrumentationNodeJS=${AUTO_INSTRUMENTATION_NODEJS_VERSION} -X ${VERSION_PKG}.autoInstrumentationPython=${AUTO_INSTRUMENTATION_PYTHON_VERSION} -X ${VERSION_PKG}.autoInstrumentationDotNet=${AUTO_INSTRUMENTATION_DOTNET_VERSION} -X ${VERSION_PKG}.autoInstrumentationGo=${AUTO_INSTRUMENTATION_GO_VERSION} -X ${VERSION_PKG}.autoInstrumentationApacheHttpd=${AUTO_INSTRUMENTATION_APACHE_HTTPD_VERSION} -X ${VERSION_PKG}.autoInstrumentationNginx=${AUTO_INSTRUMENTATION_NGINX_VERSION}" -a -o manager main.go

######## Start a new stage from scratch #######
FROM scratch
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ AUTO_INSTRUMENTATION_PYTHON_VERSION ?= "$(shell grep -v '\#' versions.txt | grep
AUTO_INSTRUMENTATION_DOTNET_VERSION ?= "$(shell grep -v '\#' versions.txt | grep autoinstrumentation-dotnet | awk -F= '{print $$2}')"
AUTO_INSTRUMENTATION_GO_VERSION ?= "$(shell grep -v '\#' versions.txt | grep autoinstrumentation-go | awk -F= '{print $$2}')"
AUTO_INSTRUMENTATION_APACHE_HTTPD_VERSION ?= "$(shell grep -v '\#' versions.txt | grep autoinstrumentation-apache-httpd | awk -F= '{print $$2}')"
LD_FLAGS ?= "-X ${VERSION_PKG}.version=${VERSION} -X ${VERSION_PKG}.buildDate=${VERSION_DATE} -X ${VERSION_PKG}.otelCol=${OTELCOL_VERSION} -X ${VERSION_PKG}.targetAllocator=${TARGETALLOCATOR_VERSION} -X ${VERSION_PKG}.operatorOpAMPBridge=${OPERATOR_OPAMP_BRIDGE_VERSION} -X ${VERSION_PKG}.autoInstrumentationJava=${AUTO_INSTRUMENTATION_JAVA_VERSION} -X ${VERSION_PKG}.autoInstrumentationNodeJS=${AUTO_INSTRUMENTATION_NODEJS_VERSION} -X ${VERSION_PKG}.autoInstrumentationPython=${AUTO_INSTRUMENTATION_PYTHON_VERSION} -X ${VERSION_PKG}.autoInstrumentationDotNet=${AUTO_INSTRUMENTATION_DOTNET_VERSION} -X ${VERSION_PKG}.autoInstrumentationGo=${AUTO_INSTRUMENTATION_GO_VERSION} -X ${VERSION_PKG}.autoInstrumentationDotNet=${AUTO_INSTRUMENTATION_APACHE_HTTPD_VERSION}"
AUTO_INSTRUMENTATION_NGINX_VERSION ?= "$(shell grep -v '\#' versions.txt | grep autoinstrumentation-nginx | awk -F= '{print $$2}')"
LD_FLAGS ?= "-X ${VERSION_PKG}.version=${VERSION} -X ${VERSION_PKG}.buildDate=${VERSION_DATE} -X ${VERSION_PKG}.otelCol=${OTELCOL_VERSION} -X ${VERSION_PKG}.targetAllocator=${TARGETALLOCATOR_VERSION} -X ${VERSION_PKG}.operatorOpAMPBridge=${OPERATOR_OPAMP_BRIDGE_VERSION} -X ${VERSION_PKG}.autoInstrumentationJava=${AUTO_INSTRUMENTATION_JAVA_VERSION} -X ${VERSION_PKG}.autoInstrumentationNodeJS=${AUTO_INSTRUMENTATION_NODEJS_VERSION} -X ${VERSION_PKG}.autoInstrumentationPython=${AUTO_INSTRUMENTATION_PYTHON_VERSION} -X ${VERSION_PKG}.autoInstrumentationDotNet=${AUTO_INSTRUMENTATION_DOTNET_VERSION} -X ${VERSION_PKG}.autoInstrumentationGo=${AUTO_INSTRUMENTATION_GO_VERSION} -X ${VERSION_PKG}.autoInstrumentationApacheHttpd=${AUTO_INSTRUMENTATION_APACHE_HTTPD_VERSION} -X ${VERSION_PKG}.autoInstrumentationNginx=${AUTO_INSTRUMENTATION_NGINX_VERSION}"
ARCH ?= $(shell go env GOARCH)

# Image URL to use all building/pushing image targets
Expand Down Expand Up @@ -225,7 +226,7 @@ scorecard-tests: operator-sdk
# buildx is used to ensure same results for arm based systems (m1/2 chips)
.PHONY: container
container:
docker buildx build --load --platform linux/${ARCH} -t ${IMG} --build-arg VERSION_PKG=${VERSION_PKG} --build-arg VERSION=${VERSION} --build-arg VERSION_DATE=${VERSION_DATE} --build-arg OTELCOL_VERSION=${OTELCOL_VERSION} --build-arg TARGETALLOCATOR_VERSION=${TARGETALLOCATOR_VERSION} --build-arg OPERATOR_OPAMP_BRIDGE_VERSION=${OPERATOR_OPAMP_BRIDGE_VERSION} --build-arg AUTO_INSTRUMENTATION_JAVA_VERSION=${AUTO_INSTRUMENTATION_JAVA_VERSION} --build-arg AUTO_INSTRUMENTATION_NODEJS_VERSION=${AUTO_INSTRUMENTATION_NODEJS_VERSION} --build-arg AUTO_INSTRUMENTATION_PYTHON_VERSION=${AUTO_INSTRUMENTATION_PYTHON_VERSION} --build-arg AUTO_INSTRUMENTATION_DOTNET_VERSION=${AUTO_INSTRUMENTATION_DOTNET_VERSION} --build-arg AUTO_INSTRUMENTATION_GO_VERSION=${AUTO_INSTRUMENTATION_GO_VERSION} --build-arg AUTO_INSTRUMENTATION_APACHE_HTTPD_VERSION=${AUTO_INSTRUMENTATION_APACHE_HTTPD_VERSION} .
docker buildx build --load --platform linux/${ARCH} -t ${IMG} --build-arg VERSION_PKG=${VERSION_PKG} --build-arg VERSION=${VERSION} --build-arg VERSION_DATE=${VERSION_DATE} --build-arg OTELCOL_VERSION=${OTELCOL_VERSION} --build-arg TARGETALLOCATOR_VERSION=${TARGETALLOCATOR_VERSION} --build-arg OPERATOR_OPAMP_BRIDGE_VERSION=${OPERATOR_OPAMP_BRIDGE_VERSION} --build-arg AUTO_INSTRUMENTATION_JAVA_VERSION=${AUTO_INSTRUMENTATION_JAVA_VERSION} --build-arg AUTO_INSTRUMENTATION_NODEJS_VERSION=${AUTO_INSTRUMENTATION_NODEJS_VERSION} --build-arg AUTO_INSTRUMENTATION_PYTHON_VERSION=${AUTO_INSTRUMENTATION_PYTHON_VERSION} --build-arg AUTO_INSTRUMENTATION_DOTNET_VERSION=${AUTO_INSTRUMENTATION_DOTNET_VERSION} --build-arg AUTO_INSTRUMENTATION_GO_VERSION=${AUTO_INSTRUMENTATION_GO_VERSION} --build-arg AUTO_INSTRUMENTATION_APACHE_HTTPD_VERSION=${AUTO_INSTRUMENTATION_APACHE_HTTPD_VERSION} --build-arg AUTO_INSTRUMENTATION_NGINX_VERSION=${AUTO_INSTRUMENTATION_NGINX_VERSION} .

# Push the container image, used only for local dev purposes
.PHONY: container-push
Expand Down
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ When using sidecar mode the OpenTelemetry collector container will have the envi

### OpenTelemetry auto-instrumentation injection

The operator can inject and configure OpenTelemetry auto-instrumentation libraries. Currently Apache HTTPD, DotNet, Go, Java, NodeJS and Python are supported.
The operator can inject and configure OpenTelemetry auto-instrumentation libraries. Currently Apache HTTPD, DotNet, Go, Java, Nginx, NodeJS and Python are supported.

To use auto-instrumentation, configure an `Instrumentation` resource with the configuration for the SDK and instrumentation.

Expand Down Expand Up @@ -291,6 +291,11 @@ Apache HTTPD:
instrumentation.opentelemetry.io/inject-apache-httpd: "true"
```

Nginx:
```bash
instrumentation.opentelemetry.io/inject-nginx: "true"
```

OpenTelemetry SDK environment variables only:
```bash
instrumentation.opentelemetry.io/inject-sdk: "true"
Expand Down Expand Up @@ -365,6 +370,8 @@ spec:
image: your-customized-auto-instrumentation-image:go
apacheHttpd:
image: your-customized-auto-instrumentation-image:apache-httpd
nginx:
image: your-customized-auto-instrumentation-image:nginx
```

The Dockerfiles for auto-instrumentation can be found in [autoinstrumentation directory](./autoinstrumentation).
Expand All @@ -390,6 +397,26 @@ metadata:
```
List of all available attributes can be found at [otel-webserver-module](https://github.com/open-telemetry/opentelemetry-cpp-contrib/tree/main/instrumentation/otel-webserver-module)

#### Using Nginx autoinstrumentation

For `Nginx` autoinstrumentation, Nginx versions 1.22.0, 1.23.0, and 1.23.1 are supported at this time. The Nginx configuration file is expected to be `/etc/nginx/nginx.conf` by default, if it's different, see following example on how to change it. Instrumentation at this time also expects, that `conf.d` directory is present in the directory, where configuration file resides and that there is a `include <config-file-dir-path>/conf.d/*.conf;` directive in the `http { ... }` section of Nginx configuration file (like it is in the default configuration file of Nginx). You can also adjust OpenTelemetry SDK attributes. Example:

```yaml
apiVersion: opentelemetry.io/v1alpha1
kind: Instrumentation
metadata:
name: my-instrumentation
nginx:
image: your-customized-auto-instrumentation-image:nginx # if custom instrumentation image is needed
configFile: /my/custom-dir/custom-nginx.conf
attrs:
- name: NginxModuleOtelMaxQueueSize
value: "4096"
- name: ...
value: ...
```
List of all available attributes can be found at [otel-webserver-module](https://github.com/open-telemetry/opentelemetry-cpp-contrib/tree/main/instrumentation/otel-webserver-module)

#### Inject OpenTelemetry SDK environment variables only

You can configure the OpenTelemetry SDK for applications which can't currently be autoinstrumented by using `inject-sdk` in place of `inject-python` or `inject-java`, for example. This will inject environment variables like `OTEL_RESOURCE_ATTRIBUTES`, `OTEL_TRACES_SAMPLER`, and `OTEL_EXPORTER_OTLP_ENDPOINT`, that you can configure in the `Instrumentation`, but will not actually provide the SDK.
Expand All @@ -415,6 +442,7 @@ If a language is enabled by default its gate only needs to be supplied when disa
| DotNet | `operator.autoinstrumentation.dotnet` | enabled |
| ApacheHttpD | `operator.autoinstrumentation.apache-httpd` | enabled |
| Go | `operator.autoinstrumentation.go` | disabled |
| Nginx | `operator.autoinstrumentation.nginx` | disabled |

Language not specified in the table are always supported and cannot be disabled.

Expand Down
2 changes: 2 additions & 0 deletions apis/v1alpha1/instrumentation_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func TestInstrumentationDefaultingWebhook(t *testing.T) {
AnnotationDefaultAutoInstrumentationPython: "python-img:1",
AnnotationDefaultAutoInstrumentationDotNet: "dotnet-img:1",
AnnotationDefaultAutoInstrumentationApacheHttpd: "apache-httpd-img:1",
AnnotationDefaultAutoInstrumentationNginx: "nginx-img:1",
},
},
}
Expand All @@ -39,6 +40,7 @@ func TestInstrumentationDefaultingWebhook(t *testing.T) {
assert.Equal(t, "python-img:1", inst.Spec.Python.Image)
assert.Equal(t, "dotnet-img:1", inst.Spec.DotNet.Image)
assert.Equal(t, "apache-httpd-img:1", inst.Spec.ApacheHttpd.Image)
assert.Equal(t, "nginx-img:1", inst.Spec.Nginx.Image)
}

func TestInstrumentationValidatingWebhook(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ metadata:
categories: Logging & Tracing,Monitoring
certified: "false"
containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
createdAt: "2023-09-20T15:05:15Z"
createdAt: "2023-09-28T06:52:11Z"
description: Provides the OpenTelemetry components, including the Collector
operators.operatorframework.io/builder: operator-sdk-v1.29.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
Expand Down Expand Up @@ -287,7 +287,7 @@ spec:
- --enable-leader-election
- --zap-log-level=info
- --zap-time-encoding=rfc3339nano
- --feature-gates=+operator.autoinstrumentation.go
- --feature-gates=+operator.autoinstrumentation.go,+operator.autoinstrumentation.nginx
image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.85.0
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion config/default/manager_auth_proxy_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ spec:
- "--enable-leader-election"
- "--zap-log-level=info"
- "--zap-time-encoding=rfc3339nano"
- "--feature-gates=+operator.autoinstrumentation.go"
- "--feature-gates=+operator.autoinstrumentation.go,+operator.autoinstrumentation.nginx"
7 changes: 7 additions & 0 deletions internal/config/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type Config struct {
autoInstrumentationDotNetImage string
autoInstrumentationGoImage string
autoInstrumentationApacheHttpdImage string
autoInstrumentationNginxImage string
targetAllocatorConfigMapEntry string
autoInstrumentationNodeJSImage string
autoInstrumentationJavaImage string
Expand Down Expand Up @@ -85,6 +86,7 @@ func New(opts ...Option) Config {
autoInstrumentationPythonImage: o.autoInstrumentationPythonImage,
autoInstrumentationDotNetImage: o.autoInstrumentationDotNetImage,
autoInstrumentationApacheHttpdImage: o.autoInstrumentationApacheHttpdImage,
autoInstrumentationNginxImage: o.autoInstrumentationNginxImage,
labelsFilter: o.labelsFilter,
}
}
Expand Down Expand Up @@ -184,6 +186,11 @@ func (c *Config) AutoInstrumentationApacheHttpdImage() string {
return c.autoInstrumentationApacheHttpdImage
}

// AutoInstrumentationNginxImage returns OpenTelemetry Nginx auto-instrumentation container image.
func (c *Config) AutoInstrumentationNginxImage() string {
return c.autoInstrumentationNginxImage
}

// LabelsFilter Returns the filters converted to regex strings used to filter out unwanted labels from propagations.
func (c *Config) LabelsFilter() []string {
return c.labelsFilter
Expand Down
7 changes: 7 additions & 0 deletions internal/config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type options struct {
autoInstrumentationNodeJSImage string
autoInstrumentationPythonImage string
autoInstrumentationApacheHttpdImage string
autoInstrumentationNginxImage string
collectorImage string
collectorConfigMapEntry string
targetAllocatorConfigMapEntry string
Expand Down Expand Up @@ -145,6 +146,12 @@ func WithAutoInstrumentationApacheHttpdImage(s string) Option {
}
}

func WithAutoInstrumentationNginxImage(s string) Option {
return func(o *options) {
o.autoInstrumentationNginxImage = s
}
}

func WithLabelFilters(labelFilters []string) Option {
return func(o *options) {

Expand Down
13 changes: 12 additions & 1 deletion internal/version/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var (
autoInstrumentationPython string
autoInstrumentationDotNet string
autoInstrumentationApacheHttpd string
autoInstrumentationNginx string
autoInstrumentationGo string
)

Expand All @@ -48,6 +49,7 @@ type Version struct {
AutoInstrumentationDotNet string `json:"auto-instrumentation-dotnet"`
AutoInstrumentationGo string `json:"auto-instrumentation-go"`
AutoInstrumentationApacheHttpd string `json:"auto-instrumentation-apache-httpd"`
AutoInstrumentationNginx string `json:"auto-instrumentation-nginx"`
}

// Get returns the Version object with the relevant information.
Expand All @@ -65,12 +67,13 @@ func Get() Version {
AutoInstrumentationDotNet: AutoInstrumentationDotNet(),
AutoInstrumentationGo: AutoInstrumentationGo(),
AutoInstrumentationApacheHttpd: AutoInstrumentationApacheHttpd(),
AutoInstrumentationNginx: AutoInstrumentationNginx(),
}
}

func (v Version) String() string {
return fmt.Sprintf(
"Version(Operator='%v', BuildDate='%v', OpenTelemetryCollector='%v', Go='%v', TargetAllocator='%v', OperatorOpAMPBridge='%v', AutoInstrumentationJava='%v', AutoInstrumentationNodeJS='%v', AutoInstrumentationPython='%v', AutoInstrumentationDotNet='%v', AutoInstrumentationGo='%v', AutoInstrumentationApacheHttpd='%v')",
"Version(Operator='%v', BuildDate='%v', OpenTelemetryCollector='%v', Go='%v', TargetAllocator='%v', OperatorOpAMPBridge='%v', AutoInstrumentationJava='%v', AutoInstrumentationNodeJS='%v', AutoInstrumentationPython='%v', AutoInstrumentationDotNet='%v', AutoInstrumentationGo='%v', AutoInstrumentationApacheHttpd='%v', AutoInstrumentationNginx='%v')",
v.Operator,
v.BuildDate,
v.OpenTelemetryCollector,
Expand All @@ -83,6 +86,7 @@ func (v Version) String() string {
v.AutoInstrumentationDotNet,
v.AutoInstrumentationGo,
v.AutoInstrumentationApacheHttpd,
v.AutoInstrumentationNginx,
)
}

Expand Down Expand Up @@ -154,6 +158,13 @@ func AutoInstrumentationApacheHttpd() string {
return "0.0.0"
}

func AutoInstrumentationNginx() string {
if len(autoInstrumentationNginx) > 0 {
return autoInstrumentationNginx
}
return "0.0.0"
}

func AutoInstrumentationGo() string {
if len(autoInstrumentationGo) > 0 {
return autoInstrumentationGo
Expand Down
Loading