forked from elastic/apm-server
-
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.
[beater] Restructure beater package and some more test
Create several packages inside the beater directory to better organize http framework logic. Adapt tests and code to new structure. related to elastic#2489
- Loading branch information
Showing
95 changed files
with
1,635 additions
and
1,070 deletions.
There are no files selected for viewing
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,51 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you 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 agent | ||
|
||
import ( | ||
"github.com/elastic/beats/libbeat/monitoring" | ||
|
||
"github.com/elastic/apm-server/beater/api/intake" | ||
"github.com/elastic/apm-server/beater/request" | ||
) | ||
|
||
var ( | ||
|
||
//TODO: change logic for acm specific monitoring counters | ||
//will be done in a follow up PR to avoid changing logic here | ||
//serverMetrics = monitoring.Default.NewRegistry("apm-server.server.acm", monitoring.PublishExpvar) | ||
//counter = func(s request.ResultID) *monitoring.Int { | ||
// return monitoring.NewInt(serverMetrics, string(s)) | ||
//} | ||
|
||
// reflects current behavior | ||
countRequest = intake.ResultIDToMonitoringInt(request.IDRequestCount) | ||
|
||
mapping = map[request.ResultID]*monitoring.Int{ | ||
request.IDRequestCount: countRequest, | ||
} | ||
) | ||
|
||
// ResultIDToMonitoringInt takes a request.ResultID and maps it to a monitoring counter. If no mapping is found, | ||
// nil is returned. | ||
func ResultIDToMonitoringInt(id request.ResultID) *monitoring.Int { | ||
if i, ok := mapping[id]; ok { | ||
return i | ||
} | ||
return nil | ||
} |
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,38 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you 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 agent | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/elastic/apm-server/beater/beatertest" | ||
"github.com/elastic/apm-server/beater/request" | ||
) | ||
|
||
func TestResultIdToMonitoringInt(t *testing.T) { | ||
for _, id := range beatertest.AllRequestResultIDs() { | ||
counter := ResultIDToMonitoringInt(id) | ||
if id == request.IDRequestCount { | ||
assert.NotNil(t, counter, string(id)) | ||
} else { | ||
assert.Nil(t, counter, string(id)) | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.