forked from open-telemetry/opentelemetry-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose the Prometheus exporter port when specified in the config (ope…
…n-telemetry#1953) * Expose Prometheus exporter port in the OTEL Collector Signed-off-by: Israel Blancas <[email protected]> * Format Signed-off-by: Israel Blancas <[email protected]> * Allow the usage of multiple exporters Signed-off-by: Israel Blancas <[email protected]> * Format Signed-off-by: Israel Blancas <[email protected]> * Fix tests Signed-off-by: Israel Blancas <[email protected]> * Apply changes requested in CR --------- Signed-off-by: Israel Blancas <[email protected]>
- Loading branch information
Showing
5 changed files
with
195 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
.chloggen/1689-expose-prometheusexporter-pod-when-enabled.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Expose the Prometheus exporter port in the OpenTelemetry Collector container when it is used in the configuration. | ||
|
||
# One or more tracking issues related to the change | ||
issues: [1689] | ||
|
||
# (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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package naming | ||
|
||
import ( | ||
"strings" | ||
"unicode/utf8" | ||
) | ||
|
||
// PortName returns a dns-safe string for the given name. | ||
// Any char that is not [a-z0-9] is replaced by "-" or "a". | ||
// Replacement character "a" is used only at the beginning or at the end of the name. | ||
// The function does not change length of the string. | ||
func PortName(name string) string { | ||
var d []rune | ||
|
||
for i, x := range strings.ToLower(name) { | ||
if regex.Match([]byte(string(x))) { | ||
d = append(d, x) | ||
} else if i == 0 || i == utf8.RuneCountInString(name)-1 { | ||
d = append(d, 'a') | ||
} else { | ||
d = append(d, '-') | ||
} | ||
} | ||
|
||
return string(d) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package naming | ||
|
||
import ( | ||
"regexp" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestPortName(t *testing.T) { | ||
var tests = []struct { | ||
in string | ||
out string | ||
}{ | ||
{"simplest", "simplest"}, | ||
{"prometheus/dev", "prometheus-dev"}, | ||
{"prometheus.dev", "prometheus-dev"}, | ||
{"prometheus-", "prometheusa"}, | ||
{"-prometheus", "aprometheus"}, | ||
} | ||
rule, err := regexp.Compile(`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`) | ||
assert.NoError(t, err) | ||
|
||
for _, tt := range tests { | ||
assert.Equal(t, tt.out, PortName(tt.in)) | ||
matched := rule.Match([]byte(tt.out)) | ||
assert.True(t, matched, "%v is not a valid name", tt.out) | ||
} | ||
} |