-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pyroscope.java): infer service_name label if possible (#6184)
* fix(pyroscope.java): infer service_name label if possible * Do not mutate target * update changelog, fix scrape infer * fix * fix
- Loading branch information
1 parent
49bfc29
commit fe89779
Showing
6 changed files
with
66 additions
and
0 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
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,35 @@ | ||
package java | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/grafana/agent/component/discovery" | ||
) | ||
|
||
const ( | ||
labelServiceName = "service_name" | ||
labelServiceNameK8s = "__meta_kubernetes_pod_annotation_pyroscope_io_service_name" | ||
) | ||
|
||
func inferServiceName(target discovery.Target) string { | ||
k8sServiceName := target[labelServiceNameK8s] | ||
if k8sServiceName != "" { | ||
return k8sServiceName | ||
} | ||
k8sNamespace := target["__meta_kubernetes_namespace"] | ||
k8sContainer := target["__meta_kubernetes_pod_container_name"] | ||
if k8sNamespace != "" && k8sContainer != "" { | ||
return fmt.Sprintf("java/%s/%s", k8sNamespace, k8sContainer) | ||
} | ||
dockerContainer := target["__meta_docker_container_name"] | ||
if dockerContainer != "" { | ||
return dockerContainer | ||
} | ||
if swarmService := target["__meta_dockerswarm_container_label_service_name"]; swarmService != "" { | ||
return swarmService | ||
} | ||
if swarmService := target["__meta_dockerswarm_service_name"]; swarmService != "" { | ||
return swarmService | ||
} | ||
return "unspecified" | ||
} |
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