-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compute apmStats in the server. (#21067)
- Handle communicating with the trace-agent in the status package - Update the GUI to rende the apmStats using the informatoin from the server rather than using AJAX
- Loading branch information
1 parent
3f5d700
commit d13e6ec
Showing
8 changed files
with
118 additions
and
114 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,59 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2016-present Datadog, Inc. | ||
|
||
// Package apm fetch information about the apm agent. | ||
// This will, in time, be migrated to the apm agent component. | ||
package apm | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
"sync" | ||
|
||
apiutil "github.com/DataDog/datadog-agent/pkg/api/util" | ||
"github.com/DataDog/datadog-agent/pkg/config" | ||
) | ||
|
||
// httpClients should be reused instead of created as needed. They keep cached TCP connections | ||
// that may leak otherwise | ||
var ( | ||
httpClient *http.Client | ||
clientInitOnce sync.Once | ||
) | ||
|
||
func client() *http.Client { | ||
clientInitOnce.Do(func() { | ||
httpClient = apiutil.GetClient(false) | ||
}) | ||
|
||
return httpClient | ||
} | ||
|
||
// GetAPMStatus returns a set of key/value pairs summarizing the status of the trace-agent. | ||
// If the status can not be obtained for any reason, the returned map will contain an "error" | ||
// key with an explanation. | ||
func GetAPMStatus() map[string]interface{} { | ||
port := config.Datadog.GetInt("apm_config.debug.port") | ||
|
||
c := client() | ||
url := fmt.Sprintf("http://localhost:%d/debug/vars", port) | ||
resp, err := apiutil.DoGet(c, url, apiutil.CloseConnection) | ||
if err != nil { | ||
return map[string]interface{}{ | ||
"port": port, | ||
"error": err.Error(), | ||
} | ||
} | ||
|
||
status := make(map[string]interface{}) | ||
if err := json.Unmarshal(resp, &status); err != nil { | ||
return map[string]interface{}{ | ||
"port": port, | ||
"error": err.Error(), | ||
} | ||
} | ||
return status | ||
} |
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