Skip to content

Commit

Permalink
Merge branch 'main' into add_shutdown_podman
Browse files Browse the repository at this point in the history
  • Loading branch information
rogercoll authored May 13, 2024
2 parents 863440d + d43a904 commit 31624bb
Show file tree
Hide file tree
Showing 40 changed files with 2,669 additions and 61,232 deletions.
27 changes: 27 additions & 0 deletions .chloggen/feat_vcenter-performance-tweaks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# 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. filelogreceiver)
component: vcenterreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Refactors how and when client makes calls in order to provide for faster collection times."

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [31837]

# (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:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
27 changes: 27 additions & 0 deletions .chloggen/hec-ack-alignment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# 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. filelogreceiver)
component: splunkhecreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Make the channelID header check case-insensitive and allow hecreceiver endpoints able to extract channelID from query params

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [32995]

# (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:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ exporter/otelarrowexporter/ @open-telemetry/collect
exporter/prometheusexporter/ @open-telemetry/collector-contrib-approvers @Aneurysm9
exporter/prometheusremotewriteexporter/ @open-telemetry/collector-contrib-approvers @Aneurysm9 @rapphil
exporter/pulsarexporter/ @open-telemetry/collector-contrib-approvers @dmitryax @dao-jun
exporter/rabbitmqexporter/ @open-telemetry/collector-contrib-approvers @swar8080
exporter/rabbitmqexporter/ @open-telemetry/collector-contrib-approvers @swar8080 @atoulme
exporter/sapmexporter/ @open-telemetry/collector-contrib-approvers @dmitryax @atoulme
exporter/sentryexporter/ @open-telemetry/collector-contrib-approvers @AbhiPrasad
exporter/signalfxexporter/ @open-telemetry/collector-contrib-approvers @dmitryax @crobert-1
Expand Down
2 changes: 1 addition & 1 deletion exporter/rabbitmqexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
| Stability | [development]: traces, metrics, logs |
| Distributions | [] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aexporter%2Frabbitmq%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aexporter%2Frabbitmq) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aexporter%2Frabbitmq%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aexporter%2Frabbitmq) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@swar8080](https://www.github.com/swar8080) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@swar8080](https://www.github.com/swar8080), [@atoulme](https://www.github.com/atoulme) |

[development]: https://github.com/open-telemetry/opentelemetry-collector#development
<!-- end autogenerated section -->
Expand Down
2 changes: 1 addition & 1 deletion exporter/rabbitmqexporter/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ status:
development: [traces, metrics, logs]
distributions: []
codeowners:
active: [swar8080]
active: [swar8080, atoulme]

tests:
skip_lifecycle: true
Expand Down
21 changes: 15 additions & 6 deletions receiver/splunkhecreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ func (r *splunkReceiver) handleAck(resp http.ResponseWriter, req *http.Request)

var channelID string
var extracted bool
if channelID, extracted = r.extractChannelHeader(req); extracted {
if channelID, extracted = r.extractChannel(req); extracted {
if channelErr := r.validateChannelHeader(channelID); channelErr != nil {
r.failRequest(ctx, resp, http.StatusBadRequest, []byte(channelErr.Error()), 0, channelErr)
return
Expand Down Expand Up @@ -327,7 +327,7 @@ func (r *splunkReceiver) handleRawReq(resp http.ResponseWriter, req *http.Reques

var channelID string
var extracted bool
if channelID, extracted = r.extractChannelHeader(req); extracted {
if channelID, extracted = r.extractChannel(req); extracted {
if channelErr := r.validateChannelHeader(channelID); channelErr != nil {
r.failRequest(ctx, resp, http.StatusBadRequest, []byte(channelErr.Error()), 0, channelErr)
return
Expand Down Expand Up @@ -391,9 +391,18 @@ func (r *splunkReceiver) handleRawReq(resp http.ResponseWriter, req *http.Reques
}
}

func (r *splunkReceiver) extractChannelHeader(req *http.Request) (string, bool) {
if headers, ok := req.Header[splunk.HTTPSplunkChannelHeader]; ok {
return headers[0], true
func (r *splunkReceiver) extractChannel(req *http.Request) (string, bool) {
// check header
for k, v := range req.Header {
if strings.EqualFold(k, splunk.HTTPSplunkChannelHeader) {
return strings.ToUpper(v[0]), true
}
}
// check query param
for k, v := range req.URL.Query() {
if strings.EqualFold(k, "channel") {
return strings.ToUpper(v[0]), true
}
}

return "", false
Expand Down Expand Up @@ -434,7 +443,7 @@ func (r *splunkReceiver) handleReq(resp http.ResponseWriter, req *http.Request)
return
}

channelID, extracted := r.extractChannelHeader(req)
channelID, extracted := r.extractChannel(req)
if extracted {
if channelErr := r.validateChannelHeader(channelID); channelErr != nil {
r.failRequest(ctx, resp, http.StatusBadRequest, []byte(channelErr.Error()), 0, channelErr)
Expand Down
158 changes: 155 additions & 3 deletions receiver/splunkhecreceiver/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,65 @@ func Test_splunkhecReceiver_handleAck(t *testing.T) {
}}, body)
},
},
{
name: "happy_path_with_case_insensitive_header",
req: func() *http.Request {
msgBytes, err := json.Marshal(buildSplunkHecAckMsg([]uint64{1, 2, 3}))
require.NoError(t, err)
req := httptest.NewRequest("POST", "http://localhost/ack", bytes.NewReader(msgBytes))
req.Header.Set("x-splunk-request-channel", "fbd3036f-0f1c-4e98-b71c-d4cd61213f90")
return req
}(),
setupMockAckExtension: func() component.Component {
return &mockAckExtension{
queryAcks: func(_ string, _ []uint64) map[uint64]bool {
return map[uint64]bool{
1: true,
2: false,
3: true,
}
},
}
},
assertResponse: func(t *testing.T, resp *http.Response, body any) {
status := resp.StatusCode
assert.Equal(t, http.StatusOK, status)
assert.Equal(t, map[string]any{"acks": map[string]any{
"1": true,
"2": false,
"3": true,
}}, body)
},
},
{
name: "happy_path_with_query_param",
req: func() *http.Request {
msgBytes, err := json.Marshal(buildSplunkHecAckMsg([]uint64{1, 2, 3}))
require.NoError(t, err)
req := httptest.NewRequest("POST", "http://localhost/ack?channel=fbd3036f-0f1c-4e98-b71c-d4cd61213f90", bytes.NewReader(msgBytes))
return req
}(),
setupMockAckExtension: func() component.Component {
return &mockAckExtension{
queryAcks: func(_ string, _ []uint64) map[uint64]bool {
return map[uint64]bool{
1: true,
2: false,
3: true,
}
},
}
},
assertResponse: func(t *testing.T, resp *http.Response, body any) {
status := resp.StatusCode
assert.Equal(t, http.StatusOK, status)
assert.Equal(t, map[string]any{"acks": map[string]any{
"1": true,
"2": false,
"3": true,
}}, body)
},
},
}

for _, tt := range tests {
Expand Down Expand Up @@ -1340,7 +1399,7 @@ func Test_splunkhecReceiver_handleRawReq_WithAck(t *testing.T) {
config.Ack.Extension = &id
currentTime := float64(time.Now().UnixNano()) / 1e6
splunkMsg := buildSplunkHecMsg(currentTime, 3)

currAckID := uint64(0)
tests := []struct {
name string
req *http.Request
Expand Down Expand Up @@ -1410,13 +1469,57 @@ func Test_splunkhecReceiver_handleRawReq_WithAck(t *testing.T) {
setupMockAckExtension: func() component.Component {
return &mockAckExtension{
processEvent: func(_ string) (ackID uint64) {
return uint64(1)
currAckID++
return currAckID
},
ack: func(_ string, _ uint64) {},
}
},
assertResponse: func(t *testing.T, resp *http.Response, body any) {
assertHecSuccessResponseWithAckID(t, resp, body, 1)
assertHecSuccessResponseWithAckID(t, resp, body, currAckID)
},
},
{
name: "happy_path_with_case_insensitive_header",
req: func() *http.Request {
msgBytes, err := json.Marshal(splunkMsg)
require.NoError(t, err)
req := httptest.NewRequest("POST", "http://localhost/foo", bytes.NewReader(msgBytes))
req.Header.Set("x-splunk-request-channel", "fbd3036f-0f1c-4e98-b71c-d4cd61213f90")
return req
}(),
setupMockAckExtension: func() component.Component {
return &mockAckExtension{
processEvent: func(_ string) (ackID uint64) {
currAckID++
return currAckID
},
ack: func(_ string, _ uint64) {},
}
},
assertResponse: func(t *testing.T, resp *http.Response, body any) {
assertHecSuccessResponseWithAckID(t, resp, body, currAckID)
},
},
{
name: "happy_path_with_query_param",
req: func() *http.Request {
msgBytes, err := json.Marshal(splunkMsg)
require.NoError(t, err)
req := httptest.NewRequest("POST", "http://localhost/foo?Channel=fbd3036f-0f1c-4e98-b71c-d4cd61213f90", bytes.NewReader(msgBytes))
return req
}(),
setupMockAckExtension: func() component.Component {
return &mockAckExtension{
processEvent: func(_ string) (ackID uint64) {
currAckID++
return currAckID
},
ack: func(_ string, _ uint64) {},
}
},
assertResponse: func(t *testing.T, resp *http.Response, body any) {
assertHecSuccessResponseWithAckID(t, resp, body, currAckID)
},
},
}
Expand Down Expand Up @@ -1554,6 +1657,55 @@ func Test_splunkhecReceiver_handleReq_WithAck(t *testing.T) {
assert.Equal(t, 1, len(sink.AllLogs()))
},
},
{
name: "msg_accepted_with_case_insensitive_header",
req: func() *http.Request {
msgBytes, err := json.Marshal(splunkMsg)
require.NoError(t, err)
req := httptest.NewRequest("POST", "http://localhost/foo", bytes.NewReader(msgBytes))
req.Header.Set("x-splunk-request-channel", "fbd3036f-0f1c-4e98-b71c-d4cd61213f90")
return req
}(),
setupMockAckExtension: func() component.Component {
return &mockAckExtension{
processEvent: func(_ string) (ackID uint64) {
return uint64(1)
},
ack: func(_ string, _ uint64) {
},
}
},
assertResponse: func(t *testing.T, resp *http.Response, body any) {
assertHecSuccessResponseWithAckID(t, resp, body, 1)
},
assertSink: func(t *testing.T, sink *consumertest.LogsSink) {
assert.Equal(t, 1, len(sink.AllLogs()))
},
},
{
name: "msg_accepted_with_query_param",
req: func() *http.Request {
msgBytes, err := json.Marshal(splunkMsg)
require.NoError(t, err)
req := httptest.NewRequest("POST", "http://localhost/foo?channel=fbd3036f-0f1c-4e98-b71c-d4cd61213f90&isCheesy=true", bytes.NewReader(msgBytes))
return req
}(),
setupMockAckExtension: func() component.Component {
return &mockAckExtension{
processEvent: func(_ string) (ackID uint64) {
return uint64(1)
},
ack: func(_ string, _ uint64) {
},
}
},
assertResponse: func(t *testing.T, resp *http.Response, body any) {
assertHecSuccessResponseWithAckID(t, resp, body, 1)
},
assertSink: func(t *testing.T, sink *consumertest.LogsSink) {
assert.Equal(t, 1, len(sink.AllLogs()))
},
},
}

for _, tt := range tests {
Expand Down
Loading

0 comments on commit 31624bb

Please sign in to comment.